﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using DevComponents.DotNetBar;
namespace DoAnTN.GUI
{
    public partial class frmMain : Form
    {
        public int i = 1;
        public frmMain()
        {
            InitializeComponent();
        }

        private void tabContel_TabItemClose(object sender, DevComponents.DotNetBar.TabStripActionEventArgs e)
        {
            tabContel.Tabs.Remove(tabContel.SelectedTab);
        }

        public void AddNewTab(string strName, UserControl ucContent, string link)
        {
            foreach (TabItem tabPage in tabContel.Tabs)
                if (tabPage.Text == strName)
                {
                    tabContel.SelectedTab = tabPage;
                    return;
                }
            TabControlPanel newTabPanel = new DevComponents.DotNetBar.TabControlPanel();
            TabItem newTabPage = new TabItem(this.components);
            newTabPanel.Dock = System.Windows.Forms.DockStyle.Fill;
            newTabPanel.Location = new System.Drawing.Point(0, 26);
            newTabPanel.Name = "panel" + strName;
            newTabPanel.Padding = new System.Windows.Forms.Padding(1);
            newTabPanel.Size = new System.Drawing.Size(1284, 436);
            newTabPanel.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(142)))), ((int)(((byte)(179)))), ((int)(((byte)(231)))));
            newTabPanel.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(237)))), ((int)(((byte)(254)))));
            newTabPanel.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine;
            newTabPanel.Style.BorderColor.Color = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(97)))), ((int)(((byte)(156)))));
            newTabPanel.Style.BorderSide = ((DevComponents.DotNetBar.eBorderSide)(((DevComponents.DotNetBar.eBorderSide.Left | DevComponents.DotNetBar.eBorderSide.Right)
                        | DevComponents.DotNetBar.eBorderSide.Bottom)));
            newTabPanel.Style.GradientAngle = 90;
            newTabPanel.TabIndex = 2;
            newTabPanel.TabItem = newTabPage;

            //-------------------------New tag page--------------------//
            Random ran = new Random();
            newTabPage.Name = strName + ran.Next(100000) + ran.Next(22342);
            newTabPage.AttachedControl = newTabPanel;
            newTabPage.Image = Image.FromFile(link);
            newTabPage.Text = strName;
            ucContent.Dock = DockStyle.Fill;
            newTabPanel.Controls.Add(ucContent);

            //----------------------Add tag page--------------------------//
            tabContel.Controls.Add(newTabPanel);
            tabContel.Tabs.Add(newTabPage);
            tabContel.SelectedTab = newTabPage;
        }

        private void soDoPhongToolStripMenuItem_Click(object sender, EventArgs e)
        {
            UCSoDoPhong uCSoDoPhong = new UCSoDoPhong();
            AddNewTab("Sơ đồ phòng",uCSoDoPhong,"C:\\Users\\vubinh\\Desktop\\DoAnTN\\DoAnTN\\Icon\\22x22\\addnew.png");
        }

        private void timerGio_Tick(object sender, EventArgs e)
        {
            DateTime dt = DateTime.Now;
            lblGio.Text = String.Format("{0:HH:mm:ss - dd/MM/yyyy}", dt);
        }

        private void timerChuChay_Tick(object sender, EventArgs e)
        {
            labelCopyright.Left -= i;
            if (labelCopyright.Right < 0)
            {
                labelCopyright.Left = this.Width;
            }
        }


    }
}
